package org.syncsoft.overalt.communication.api;

import java.io.File;
import java.util.List;

import org.apache.http.HttpResponse;
import org.syncsoft.overalt.common.api.Parameter;
import org.syncsoft.overalt.communication.exception.ConnectionException;

/**
 * 
 * status of connection
 * 
 * @pattern status
 * @author tptfc
 *
 */
public interface IConnectionStatus {	
	/**
	 * @precondition	(login && password) valid user server data;
	 * 					this method can't be executed in parallel with "close" method;
	 *   
	 * @postcondition established the connection between server and client
	 */
	void open();
	
	/**
	 * @precondition this method can't be executed in parallel with "open" method
	 * @postcondition close the connection between server and client
	 */
	void close();
	
	/**
	 * @return
	 */
	boolean isConnected();
	
	/**
	 * @precondition connection established between server and client
	 * @postcondition execute a HTTP request to uri using the POST method
	 * 
	 * @param uri
	 * @param parameters
	 * @return the request entity
	 * 
	 */
	HttpResponse get(String uri, List<Parameter> parameters);
	
	/**
	 * @precondition connection established between server and client
	 * @postcondition execute a HTTP request to uri using the POST method
	 * 
	 * @param url
	 * @param parameters
	 * @return the request entity
	 * 
	 */
	HttpResponse post(String uri, List<Parameter> parameters);
	
	/**
	 * @precondition connection established between server and client
	 * @postcondition execute a HTTP request to uri using the POST method
	 * 
	 * @param url
	 * @param parameters
	 * @return the request entity
	 * 
	 * @throws ConnectionException
	 */
	HttpResponse postMultipart(String uri, List<Parameter> parameters, String fileEntityName, File file);
}
